<?php

defined('_JEXEC') or die('Restricted access'); 
JHTML::_('behavior.tooltip'); 
 
$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
$saveOrder	= $listOrder == 'c.ordering';
$user = &JFactory::getUser();
?>

<script type="text/javascript">
function submitform(pressbutton)
{
	var form = document.adminForm;
   	if (pressbutton)
    {form.task.value=pressbutton;}

	if ((pressbutton=='add')||(pressbutton=='publish') ||(pressbutton=='unpublish')||(pressbutton=='remove'))
	{
	  	form.controller.value="oclub";
	}
	try 
	{
		form.onsubmit();
	}
	catch(e){}
	form.submit();
}
</script>
<form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
	<?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
    	<div id="filter-bar" class="btn-toolbar">
		<div class="filter-search btn-group pull-left fltlft">
			<label for="filter_search" class="element-invisible">Search</label>
			<input type="text" name="search" id="search" 
			placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" 
			value="<?php echo $this->search ?>"  title="" />
		</div>		
		<div class="filter-search btn-group pull-left fltlft">
			<button type="submit" class="btn"><i class="icon-search"></i></button>
			<button type="button" class="btn" onclick="document.id('search').value=''; this.form.submit();"><i class="icon-remove"></i></button>
		</div>
		<div class="btn-group pull-right hidden-phone fltrt">
			<?php
				echo $this->lists['published'];
				echo $this->lists['user'];
			?>
		</div>
	</div>
	<br clear="all">
    <div id="editcell">
		<table class="table table-striped adminlist">
		<thead>
			<tr>
				<th width="5">
					<?php echo JText::_( 'NUM' ); ?>
				</th>
				<th width="20">
					<?php echo JHtml::_('grid.checkall'); ?>
				</th>
				<th width="20">
					<?php echo JHTML::_('grid.sort',  'ID', 'c.id', $listDirn, $listOrder ); ?>
				</th>
           		<th class="title" width="30%">
                	<?php echo JHTML::_('grid.sort',  'Club Name', 'c.name', $listDirn, $listOrder ); ?>
               	</th>
				<th width="10%">
					<?php echo JHtml::_('grid.sort',  'JGRID_HEADING_ORDERING', 'c.ordering', $listDirn, $listOrder); ?>
						<?php if ($saveOrder) :?>
							<?php echo JHtml::_('grid.order',  $this->items, 'filesave.png', 'saveorder'); ?>
						<?php endif; ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Created by ', 'u.name', $listDirn, $listOrder ); ?>
				</th>
                <th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Created date ', 'c.created_date',$listDirn, $listOrder ); ?>
				</th>
                <th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Published', 'c.published', $listDirn, $listOrder ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
           $k = 0;
		for ($i=0, $n= count( $this->items ); $i < $n; $i++):
			$ordering	= ($listOrder == 'c.ordering');
			$row = &$this->items[$i];
			$checked 	= JHTML::_('grid.checkedout',   $row, $i);
            $canChange	= $user->authorise('core.edit.state', 'com_wrd.oclub.'.$row->id);
			$published 	= JHTML::_('jgrid.published', $row->published, $i,'oclub.', $canChange,'cb');
			?>
			<tr class="<?php echo "row$k"; ?>"  >
                <td>
					<?php echo($i+1); ?>
				</td>
                <td>
					<?php echo $checked; ?>
				</td>
				<td>
					<?php echo $row->id; ?>
				</td>
				<td>
					<a href="index.php?option=com_wrd&controller=oclub&id=<?php echo $row->id ?>&layout=form"><?php echo $row->old_club_name; ?></a>
				</td>
				<td class="order">
					<?php if ($canChange) : ?>
						<?php if ($saveOrder) :?>
							<?php if ($listDirn == 'asc') : ?>
								<span><?php echo $this->pagination->orderUpIcon($i, true, 'orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?></span>
								<span><?php echo $this->pagination->orderDownIcon($i, $this->pagination->total, true, 'orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?></span>
								<?php elseif ($listDirn == 'desc') : ?>
									<span><?php echo $this->pagination->orderUpIcon($i, true, 'orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?></span>
									<span><?php echo $this->pagination->orderDownIcon($i, $this->pagination->total, true, 'orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?></span>
								<?php endif; ?>
								<?php endif; ?>
									<?php $disabled = $saveOrder ?  '' : 'disabled="disabled"'; ?>
									<input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" <?php echo $disabled ?> class="text-area-order" />
								<?php else : ?>
									<?php echo $row->ordering; ?>
					<?php endif; ?>
				</td>
				<td>
					<?php echo $row->user_name; ?>
				</td>
                <td>
					<?php echo $row->created_date; ?>
				</td>
                <td>
					<?php echo $published; ?>
				</td>
				
			</tr>
			<?php
            $k = 1 - $k;
		endfor
		?>
		</tbody>

		<tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
		</table>
	</div>

	<input type="hidden" name="controller" value="oclub" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>